crypto = require 'crypto'
java = require('./java_instance').getJavaInstance()

winnoticeUtil = java.newInstanceSync("WinnoticeUtil2","test", "teeess")

# 加密
encrypt = (price) ->
  price = java.newDouble(price)
  return winnoticeUtil.encodePriceSync(price)

# 解密
decrypt = (str) ->
  return winnoticeUtil.decodePriceSync(str)

module.exports = 
  encrypt: encrypt
  decrypt: decrypt

# console.log "#{decrypt("XJwszwAM1ShpYgxpFjZCHnpjOT-uc5s7eH0PzA==")}"

# for i in [0..100000]
#   _price = i
#   _str = encrypt _price 
#   console.log "str: #{_str}"
#   console.log "#{decrypt(_str)}"